layui.use(["element", "layer"], function () {
    var layer = layui.layer, $ = layui.jquery, element = layui.element;
    $(".layui-custom-flexible").on("click", function () {
        var info = $(".layui-custom-body").hasClass("layui-custom-admin");
        if (info == true) {
            $(".layui-custom-body").removeClass("layui-custom-admin");
        } else {
            $(".layui-custom-body").addClass("layui-custom-admin");
            $(".layui-custom-menu .layui-nav-item").removeClass("layui-nav-itemed");
        }
    });
    element.on('nav(menu)', function(elem){
        $(".layui-custom-body").removeClass("layui-custom-admin");
        var path=$(elem).attr("lay-id");
        var title=$(elem).html();
        var id=$(elem).attr("content");
        var content=true;
        $(".layui-custom-pagetable li").each(function (i,item) {
            var layId=$(item).attr("lay-id");
            if(id==layId){
                content=false;
            }
        });
        if(content){
            if(""!=path&&"#"!=path&&undefined!=path){
                element.tabAdd('pagetable',{
                    title:title
                    ,content:"<iframe src='"+path+"' frameborder='0' class='layui-custom-iframe'></iframe>"
                    ,id:id
                });
            }
        }
        element.tabChange("pagetable",id);
    });
});